from pprint import pprint

from selenium import webdriver

driver = webdriver.Chrome()
driver.get("https://www.baidu.com")

# 获取所有cookie
# cookies = driver.get_cookies()
# pprint(cookies)

# 获取指定cookie
pprint(driver.get_cookie("ZFY"))

# 添加cookie
dict = {"name": "xiaxuan", "value": "654321"}
driver.add_cookie(dict)
pprint(driver.get_cookie("xiaxuan"))

# 删除cookie
driver.delete_cookie("xiaxuan")
pprint(driver.get_cookie("xiaxuan"))

# 删除所有cookie
driver.delete_all_cookies()
cookies = driver.get_cookies()
pprint(cookies)

driver.quit()